<?php
	$assessment_breadcrum = $ajax->link(
		'Assessment',
		array( 'controller' => 'questiongroups', 'action' => 'ajax_get', $assessment['Assessment']['id'] ),
		array( 'update' => 'edit_div_'.$assessment['Assessment']['id'], 'indicator' => 'loading')
	);
	$questiongroup_breadcrum = $ajax->link(
		'Question Group',
		array( 'controller' => 'questiongroups', 'action' => 'ajax_edit', $currentquestion['Questiongroup']['id'] ),
		array( 'update' => 'edit_div_'.$assessment['Assessment']['id'], 'indicator' => 'loading')
	);
	
	$question_breadcrum = $ajax->link(
		'Questions',
		array( 'controller' => 'questions', 'action' => 'ajax_get', $currentquestion['Questiongroup']['id'] ),
		array( 'update' => 'edit_div_'.$assessment['Assessment']['id'], 'indicator' => 'loading')
	);
	
	$answers_breadcrum = $ajax->link(
		'Answers',
		array( 'controller' => 'answers', 'action' => 'ajax_get', $currentquestion['Question']['id'] ),
		array( 'update' => 'edit_div_'.$assessment['Assessment']['id'], 'indicator' => 'loading')
	);

?>
<div id="whiteBG">
<div id="crumb"><ul>
	<li class="crumbMiddle" id="crumb01"><?php echo $assessment_breadcrum;?></li>
	<li class="crumbMiddle" id="crumb02"><?php echo $questiongroup_breadcrum;?></li>
	<li class="crumbMiddle" id="crumb03mid"><?php echo $question_breadcrum;?></li>
	<li class="crumbMiddle" id="crumb04on"><a href="#">Question</a></li>
	<li class="crumbMiddle" id="crumb05"><?php echo $answers_breadcrum;?></li>
	<li class="crumbMiddle" id="crumb06">Answer</li>
</ul></div> 
<div class="assessment">
	<div class="eTitle">
		<h2><?php 
				if(	strlen($currentquestion['Question']['name']) > 40)
					$currentquestion['Question']['name'] = substr($currentquestion['Question']['name'], 0, 40);
				echo $currentquestion['Question']['name'];
			?>
		</h2>
	</div>
	<div class="aToolbar">
		<span class="aToolbarButton">
			<span class="iconNew"></span>
			<?php
				echo $ajax->link(
					'Add An Answer',
					array( 'controller' => 'answers', 'action' => 'ajax_add', $currentquestion['Question']['id'] ),
					array( 'update' => 'edit_div_'.$assessment['Assessment']['id'], 'indicator' => 'loading')
				);
			?>
		</span>
		<span class="aToolbarButton">
			<span class="iconEdit"></span>
			<?php
				echo $ajax->link(
					'Edit Answers',
					array( 'controller' => 'answers', 'action' => 'ajax_get', $currentquestion['Question']['id'] ),
					array( 'update' => 'edit_div_'.$assessment['Assessment']['id'], 'indicator' => 'loading')
				);
			?>
		</span>
		<span class="aToolbarButton">
			<span class="iconDelete"></span>
			<?php 
				echo $ajax->link
				(
					'Delete Question',
					array( 'controller' => 'questions', 'action' => 'ajax_delete', $currentquestion['Question']['id'] ),
					array( 'update' => 'edit_div_'.$assessment['Assessment']['id'], 'confirm' => 'Are you sure?', 'indicator' => 'loading')
				);
			?>
		</span>
	</div>
<?php
	
echo $ajax->form(array('type' => 'post',
    'options' => array(
        'model'=>'Question',
        'update'=>'edit_div_'.$assessment['Assessment']['id'],
        'url' => array(
            'controller' => 'questions',
            'action' => 'ajax_edit'
        ),
    )
));

$questiongroup_close = $ajax->link(
	'[x]',
	'/assessments/blank/'.$assessment['Assessment']['id'],
	array( 'update' => 'edit_'.$assessment['Assessment']['id'] )
);

$questiongroup_close_img = str_replace('[x]','<img src="/img/close.png" border="0">',  $questiongroup_close);

# BUILD THE ANSWERS
$answer_add_ajax = $ajax->link(
	'[x]',
	array( 'controller' => 'answers', 'action' => 'ajax_add', $id ),
	array( 'update' => 'sortable_answers_'.$currentquestion['Question']['id'], 'indicator' => 'loading_answer')
);
$answer_add_ajax_img = str_replace('[x]','<img src="/img/plus.png" border="0">',  $answer_add_ajax);

$answer_refresh = $ajax->link(
	'[x]',
	array( 'controller' => 'answers', 'action' => 'ajax_get', $id),
	array( 'update' => 'sortable_answers_'.$currentquestion['Question']['id'], 'indicator' => 'loading_answer')
);
$answer_refresh_img = str_replace('[x]','<img src="/img/reload.png" border="0">',  $answer_refresh);

?>
	<div id="aForm">
		<div id="aFormLeft">
			<?php echo $form->hidden('id');?>
			<?php echo $form->input('name');?>
			<?php echo $form->input('action', array('label'=>'Action Name In World'));?>
			<?php echo $form->input('answertype_id', array('label'=>'Answer Type Options'));?>
			<?php echo $form->input('answervalue_id', array('label'=>'Answer Value Options'));?>
			<div><div>
			<?php echo $form->input('random_answers');?>
			</div><div>
			<?php echo $form->input('required_correct', array('label'=>'Require Correct Answer'));?>
			</div><div>
			<?php echo $form->input('critical');?>
			</div></div>
		</div>
		<div id="aFormRight">
			<?php echo $form->input('marks_awarded');?>
			<?php echo $form->input('question');?>
			<?php echo $form->input('incorrect_answer_helper');?>	
			<div class="right">
						<!--<a href="javascript:questionPopUp(<?php echo $id;?>)"><img src="/img/preview.png" border="0"></a>-->

						<?php echo $form->submit('Update'); ?>
						<div class="submit"><?php
						echo $ajax->link
						(
						'Cancel',
						array( 'controller' => 'questions', 'action' => 'ajax_get', $currentquestion['Questiongroup']['id'] ),
						array( 'update' => 'edit_div_'.$assessment['Assessment']['id'], 'indicator' => 'loading')
						);?>&nbsp;&nbsp;</div>
			<?php //echo $form->end();?>
				<?php 
					if(isset($flash))
						print $session->flash(); 
					unset($flash);
				?>
			</div>
		</div>
	</div>
</div>
